import axios from '../http'

const api = '/api/pay-info';

const error = (name) => (e) => console.error(name + ':=>', e);

export function upload(file, cb, fcb = error('upload')) {
  let param = new FormData(); //创建form对象
  param.append('file', file);//通过append向form对象添加数据
  let config = {headers: {'Content-Type': 'multipart/form-data'}}; //添加请求头
  axios.post('/api/upload', param, config).then(response => cb(response.data.url)).catch(err=>fcb(err));
}


export function save(params, cb, fcb = error('save')) {
  axios.post(api, params).then(d => {
    cb(d.data.content);
  }).catch(d => fcb(d));
}